/*
 * @Descriptin: 重写message弹窗功能，使弹窗信息只出现一个
 * @Version: 0.1
 * @Autor: boide gui
 * @Date: 2021-08-31 15:04:28
 * @LastEditors: boide gui
 * @LastEditTime: 2021-08-31 18:29:16
 */
import { Message } from 'element-ui'
let messageInstance = null
const resetMessage = (options) => {
  if (messageInstance) {
    messageInstance.close()
  }
  options.offset = 40
  messageInstance = Message(options)
}

['error', 'success', 'info', 'warning'].forEach(type => {
  resetMessage[type] = options => {
    if (typeof options === 'string') {
      options = {
        message: options
      }
    }
    options.type = type
    options.offset = 40
    return resetMessage(options)
  }
})
export default resetMessage
